﻿using System.Linq;
using NHibernate;
using NHibernate.Linq;

namespace Scribble.Repositories
{
    public class CategoryRepository : ICategoryRepository
    {
        private readonly ISession session;

        public CategoryRepository(ISession session)
        {
            this.session = session;
        }

        public Category GetByTitle(string urlTitle)
        {
            return session.Query<Category>()
                .FirstOrDefault(c => c.UrlTitle == urlTitle);
        }
    }
}